import { contextBridge, ipcRenderer } from "electron";
/**window进程加载器 */
const windowUtilEnum = {
    setTitle:'set-title',
    request:'request-utils',
    writeFile:'write-file',
    openFolder:'open-folder',
    selectFolder:'select-folder',
    saveLocalConfig:'save-local-config',
    getLocalConfig:'get-local-config',
    switchDevTools:'switch-dev-tools',
}
const mountWindow = () => {
    const mainProcessMethods = Object.keys(windowUtilEnum).reduce((t, v) => {
        t[v] = (...args) => {
            return ipcRenderer.invoke(windowUtilEnum[v], ...args)
        };
        return t;
    }, {})

    contextBridge.exposeInMainWorld('electron', mainProcessMethods);
}

export default mountWindow;